﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AssettDatabase
{
    public partial class Form_View_Images : Form
    {
        public ImageList imgList;
        public Form_View_Images()
        {
            InitializeComponent();
        }

        private void Form_View_Images_Load(object sender, EventArgs e)
        {
            if (imgList.Images.Count > 0)
            {
                lstImages.View = View.LargeIcon;
                lstImages.LargeImageList = imgList;
                foreach (string key in imgList.Images.Keys)
                {
                    ListViewItem item = new ListViewItem();
                    item.ImageIndex = imgList.Images.IndexOfKey(key);
                    item.Text = Path.GetFileName(key);
                    item.Tag = key;
                    lstImages.Items.Add(item);
                }

                Image image = Image.FromFile(imgList.Images.Keys[0]);
                Image mImage = new Bitmap(image);
                image.Dispose();

                imgBox.Image = mImage;
            }
        }

        private void lstImages_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void lstImages_Click(object sender, EventArgs e)
        {
            Image image = Image.FromFile(lstImages.SelectedItems[0].Tag.ToString());
            Image mImage = new Bitmap(image);
            image.Dispose();
            imgBox.Image = mImage;
        }
    }
}
